/*
 * Copyright (C) GSX Techedu Inc. All Rights Reserved
 * Unauthorized copying of this file, via any medium is strictly prohibited
 * Proprietary and confidential
 */

package com.nime.novel.crawl.constant;

/**
 * @author liujialiang
 * @description
 * @team wuhan operational dev.
 * @date 2020/8/30 3:17 下午
 **/
public enum CategoryEum {
    LS(10, "历史|军事"),
    XQ(20, "玄幻|奇幻"),
    KH(30, "科幻"),
    WX(40, "武侠|仙侠"),
    WY(50, "网游|竞技"),
    NV(60, "女生|爱情|言情"),
    DS(70, "都市"),
    QT(80, "其他"),
        ;

    private int code;
    private String desc;

    CategoryEum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static CategoryEum match(String catName) {
        for (CategoryEum categoryEum : CategoryEum.values()) {
            String [] descArray = categoryEum.getDesc().split("\\|");
            for (String desc : descArray) {
                if (catName.contains(desc)) {
                    return categoryEum;
                }
            }
        }
        return CategoryEum.QT;
    }
}
